MODULE fem_scheme_module

   USE fem_global_types
   USE fem_global_consts
!   USE fem_stats

   IMPLICIT NONE
   PRIVATE
   ! Public procedures
   PUBLIC :: fem_init_scheme,  &
             fem_get_scheme

   TYPE(fem_scheme), TARGET, SAVE :: scheme
   LOGICAL, SAVE :: scheme_initialised = .FALSE.

CONTAINS

!-------------------------------------------------------------------------------
      
   SUBROUTINE fem_get_scheme(scheme_ptr)

      IMPLICIT NONE
      TYPE(fem_scheme), POINTER :: scheme_ptr

      IF (.NOT. scheme_initialised) STOP 'fem scheme uninitialised!'
      NULLIFY(scheme_ptr)
      scheme_ptr => scheme 

   END SUBROUTINE fem_get_scheme

!-------------------------------------------------------------------------------

   SUBROUTINE fem_init_scheme(job_type)

      IMPLICIT NONE
      INTEGER(INTK), INTENT(IN) :: job_type

      scheme_initialised = .TRUE.
      scheme%FEFNthShp = 3


!      INTEGER, PARAMETER :: IO = 5

!      NAMELIST /FEM/ FEFNthShp, FEFICutWF, FEFElmEdg, &
!     &   GFCPreCond, GFCMixSolv, GFCFixSolv, GFCMixFix, &
!     &   GFCMixConvIni, GFCMixConvFin, &
!     &   GFCFixConvIni, GFCFixConvFin, &
!     &   GFCSOROMGGTF, GFCSOROMGFEF, GFCBCEval, GFCSORMAXIT, GFCSwitchDen, GFCSwitchEne, FEFBchEdg, &
!     &   FEFPotCut, GFCICutPre, &
!     &   GFCIntThr, GFCGrdThr,GFCSORConv

!      REWIND(IO)
!      READ(IO, FEM, END=9010, ERR=9000)
!      GO TO 9010
! 9000 STOP 'o Check NAMELIST FEM'
! 9010 CONTINUE

!      scheme%FEFICutWF = 10
!      scheme%GFCPreCond = 'Chole'
!      scheme%GFCMixSolv = 'PCR  '
!      scheme%GFCFixSolv = 'PCR  '
!      scheme%GFCMixFix  = 'FixGT'
!      scheme%GFCBCEval  = 'FMM  '
!      scheme%GFCSwitchDen = 1.d-01
!      scheme%GFCSwitchEne = 1.d-01
!      scheme%GFCMixConvIni = 1.d-12
!      scheme%GFCMixConvFin = 1.d-20
!      scheme%GFCFixConvIni = 1.d-20
!      scheme%GFCFixConvFin = 1.d-20
!      scheme%GFCSORConv    = 1.d-05
!      scheme%GFCSOROMGGTF  = 1.d+00
!      scheme%GFCSOROMGFEF  = 1.d+00
!      scheme%GFCSORMAXIT= 10
!      scheme%GFCICutPre = 13
!      scheme%GFCIntThr  = 11
!      scheme%GFCGrdThr  = 8
!      scheme%FEFBchEdg  = 8
!      scheme%FEFPotCut  = 1.D-99


!kura FixGTF
!      WRITE(*, *) 'GFCPreCond = ',GFCPreCond
!      WRITE(*, *) 'GFCMixSolv = ',GFCMixSolv
!      WRITE(*, *) 'GFCFixSolv = ',GFCFixSolv
!      WRITE(*, *) 'GFCMixFix  = ',GFCMixFix
!      WRITE(*, *) 'GFCBCEval  = ',GFCBCEval
!      WRITE(*, *) 'GFCSwitchDen ',GFCSwitchDen
!      WRITE(*, *) 'GFCSwitchEne ',GFCSwitchEne
!      WRITE(*, *) 'GFCMixConvIni',GFCMixConvIni
!      WRITE(*, *) 'GFCMixConvFin',GFCMixConvFin
!      WRITE(*, *) 'GFCFixConvIni',GFCFixConvIni
!      WRITE(*, *) 'GFCFixConvFin',GFCFixConvFin
!      WRITE(*, *) 'GFCSOROMGGTF ',GFCSOROMGGTF
!      WRITE(*, *) 'GFCSOROMGFEF ',GFCSOROMGFEF
!      WRITE(*, *) 'GFCSORMAXIT  ',GFCSORMAXIT
!      WRITE(*, *) 'GFCICutPre   ',GFCICutPre
!      WRITE(*, *) 'GFCIntThr    ',GFCIntThr
!      WRITE(*, *) 'GFCGrdThr    ',GFCGrdThr
!      WRITE(*, *) 'FEFBchEdg    ',FEFBchEdg
!      WRITE(*, *) 'FEFPotCut    ',FEFPotCut
!
   END SUBROUTINE fem_init_scheme

!-------------------------------------------------------------------------------

END MODULE fem_scheme_module
